function showTime(){
	var d = new Date();
	var year = d.getFullYear();
	var month = d.getMonth()+1;
	var day = d.getDate();
	var hour = d.getHours();
	var min = d.getMinutes();
	if(min<10) min = "0"+min;
	var s = d.getSeconds();
	if(s<10) s= "0"+s;
	var time = year+"-"+month+"-"+day+" "+hour+":"+min+":"+s;
	document.getElementById("span").innerHTML = time;
	return time;
}

//页面加载事件
window.onload = function(){
	showTime();
	window.setInterval(showTime,1000)
}
function sousuo(){
	//获取输入框的值
	var content = document.getElementById("content").value;
	alert("搜索内容："+content);
}



var index = 0;
function showImg(){
	var imgsLis = document.getElementById("imgs").getElementsByTagName("li");
	var numsLis = document.getElementById("nums").getElementsByTagName("li");
	for(var i = 0; i < imgsLis.length; i++) {
		if(i == index){
			imgsLis[i].style.display = 'block';
			numsLis[i].style.backgroundColor = 'red';
		} else {
			imgsLis[i].style.display = 'none';
			numsLis[i].style.backgroundColor = '#808080';
		}
	}
	index ++;
	// 边界
	if(index == imgsLis.length){
		index = 0;
	}
}


$(function($){
	$.getJSON('http://127.0.0.1:8080/AdimgsServlet',{},function(data){
		console.log(data)
		
		if(data.length == 4){
			var content = ''
			for(var i=0; i<data.length; i ++){
				content = content + '<li><a href="' + data[i].img_page + '"><img src="http://127.0.0.1:8080/'+ data[i].img_url +'" alt="'+ data[i].img_desc +'"></a></li>'
			}
			
			document.getElementById('imgs').innerHTML =content;
			
		}
		
	});
});
